home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / getdis2r / primer2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-05-23  |  3.6 KB  |  120 lines

  1. VERSION 5.00
  2. Begin VB.Form Primer 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "This program will prime you! Watch out!"
  5.    ClientHeight    =   2115
  6.    ClientLeft      =   1980
  7.    ClientTop       =   1440
  8.    ClientWidth     =   4305
  9.    ClipControls    =   0   'False
  10.    Icon            =   "PRIMER2.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    MousePointer    =   1  'Arrow
  15.    PaletteMode     =   1  'UseZOrder
  16.    ScaleHeight     =   2115
  17.    ScaleWidth      =   4305
  18.    Begin VB.CommandButton Primer 
  19.       Caption         =   "&Leave without priming the set of integers."
  20.       Height          =   375
  21.       Left            =   120
  22.       TabIndex        =   2
  23.       Top             =   1560
  24.       Width           =   3495
  25.    End
  26.    Begin VB.ListBox Primes 
  27.       Enabled         =   0   'False
  28.       Height          =   450
  29.       Left            =   120
  30.       MousePointer    =   1  'Arrow
  31.       TabIndex        =   0
  32.       Top             =   960
  33.       Width           =   3135
  34.    End
  35.    Begin VB.Image Image1 
  36.       Height          =   480
  37.       Left            =   120
  38.       Picture         =   "PRIMER2.frx":030A
  39.       Top             =   360
  40.       Width           =   480
  41.    End
  42.    Begin VB.Label John 
  43.       Caption         =   "Press on the magic wand to find a million prime numbers. Warning: this process takes a couple days."
  44.       Height          =   615
  45.       Left            =   720
  46.       TabIndex        =   1
  47.       Top             =   240
  48.       Width           =   3375
  49.       WordWrap        =   -1  'True
  50.    End
  51. Attribute VB_Name = "Primer"
  52. Attribute VB_GlobalNameSpace = False
  53. Attribute VB_Creatable = False
  54. Attribute VB_PredeclaredId = True
  55. Attribute VB_Exposed = False
  56. Dim STime
  57. Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
  58. Const MOUSEEVENTF_MOVE = &H1
  59. Const MOUSEEVENTF_ABSOLUTE = &H8000 '  absolute move
  60. Private Sub Prime()
  61. Dim Factor As Long, Doc As String, H
  62. Dim i As Long, j As Currency, MX As Long
  63. Dim rc
  64.     On Error Resume Next
  65.     MousePointer = 11
  66.     STime = Time
  67.     WindowState = 1
  68.     Primes.Clear
  69.     Primes.AddItem 2
  70.     Primes.AddItem 3
  71.     Doc = "2"
  72.     Me.Enabled = False
  73.     MX = 2
  74.     For i = 3 To 999999 Step 2
  75.         mouse_event MOUSEEVENTF_MOVE, 0, 0, 0, 0
  76.         For j = 1 To Primes.ListCount - 1
  77.             If Primes.List(j) > i / 2 Then GoTo 1
  78.             H = Primes.List(j)
  79.             If i \ H = i / H Then
  80.                 GoTo 0
  81.             ElseIf i \ H <> i / H Then
  82.                 If j = Primes.ListCount - 1 Then
  83. 1                   Primes.AddItem i
  84.                     Doc = Doc & " " & i
  85.                     MX = i
  86.                     Caption = MX
  87.                     GoTo 0
  88.                 End If
  89.             End If
  90.         Next j
  91. 0   Next i
  92.     Beep
  93.     Me.Enabled = True
  94.     Clipboard.SetText Doc
  95.     Caption = STime - Time
  96.     MousePointer = 1
  97.     John = "You have just primed the set of Computer Integers."
  98.     Caption = "&Leave after priming the set of integers."
  99.     Visible = True
  100.     WindowState = 0
  101. End Sub
  102. Private Sub Image1_Click()
  103. Dim i
  104.     Primes.Enabled = True
  105.     John = "Priming the set of integers; Please wait."
  106.     Prime
  107. End Sub
  108. Private Sub Primer_Click()
  109.     End
  110. End Sub
  111. '''''''''''''''''''''''''
  112. '   1  999   999   6    '
  113. ' 1 1 9   9 9   9 6     '
  114. '   1  9999  9999 6666  '
  115. '   1     9     9 6   6 '
  116. ' 11111  9     9   666  '
  117. '''''''''''''''''''''''''
  118. '   Feucht Production   '
  119. '''''''''''''''''''''''''
  120.